import $tool from "sept-ui/lib/utils/arms/tools.rich";

/**
 * 储存公共参数
 *  @param {登录成功返回的信息} loginResult
 * @param {用户登录的基本信息} loginInfo
 * @param {平台资源码} rscode
 */
const KeepCommonData = (loginResult, loginInfo, rscode) => {
    // 默认使用参数定义
    const CommData = {};
    CommData.bl_dept_id = loginResult.bl_dept_id||loginResult.org_dept_id;
    CommData.org_dprl_expls = loginResult.bl_dprl_expls||loginResult.org_dprl_expls; // 用户身份
    CommData.bl_dprl_expls1 = loginResult.bl_dprl_expls1; // 最新用户身份
    CommData.br_sbsbno = loginResult.br_sbsbno ? loginResult.br_sbsbno : ""; // 用户所属企业统一信用编码
    CommData.crt_date = loginResult.crt_date;
    CommData.crt_time = loginResult.crt_time;
    CommData.dept_cn_name = loginResult.dept_cn_name;
    CommData.dprl_code = loginResult.dprl_code ? loginResult.dprl_code : "";
    CommData.ent_no = loginResult.ent_no; // 所属企业ID
    CommData.ent_name = loginResult.ent_name;
    CommData.org_term_no = loginResult.term_no||loginResult.org_term_no;
    CommData.token = loginResult.token;
    CommData.orguser_cn_name = loginResult.user_cn_name||loginResult.orguser_cn_name;
    CommData.org_user_id = loginInfo.org_user_id;
    CommData.work_seq = loginResult.work_seq;
    CommData.org_channel_code = "01"; //渠道、01代表前端
    CommData.submit_type = 1;
    CommData.org_work_code = ""; //暂无
    CommData.org_dept_id = loginResult.bl_dept_id||loginResult.org_dept_id;
    CommData.orgdept_cn_name = loginResult.dept_cn_name;
    //单点跳转时传入目标系统的rscode，理论上传入的应该是目标系统的recode，此处写法是为了不排除个性化用法
    CommData.org_rs_code = rscode ? rscode : window.__GlobalConfig.rsCode;    
    CommData.is_need_token = 1; // 登录成功之后  开启验证token

    $tool.SetSessionStorage("CommData", JSON.stringify(CommData));
};

export default KeepCommonData;
